//
//  MineTableViewCell.m
//  KingSelected
//
//  Created by 杨鹏 on 2023/10/28.
//

#import "MineTableViewCell.h"

@interface MineTableViewCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UIImageView *arrowImageV;

@end

@implementation MineTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupViews];
    }
    return self;
}

- (void)setupViews {
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.imageV];
    [self.contentView addSubview:self.arrowImageV];
    
    [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(16);
        make.width.height.mas_equalTo(20);
        make.centerY.mas_equalTo(0);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.imageV.mas_trailing).offset(10);
        make.centerY.equalTo(self.imageV);
    }];
    [self.arrowImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-16);
        make.centerY.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(8, 12));
    }];
}

- (void)setModel:(MineModel *)model {
    _model = model;
    self.imageV.image = [UIImage imageNamed:model.imageStr];
    self.titleLabel.text = model.title;
}

- (UIImageView *)imageV {
    if (!_imageV) {
        _imageV = [[UIImageView alloc] init];
        _imageV.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _imageV;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = kRGB(0x333333);
        _titleLabel.font = kFontMediium(14);
        [_titleLabel sizeToFit];
    }
    return _titleLabel;
}
- (UIImageView *)arrowImageV {
    if (!_arrowImageV) {
        _arrowImageV = [[UIImageView alloc] init];
        _arrowImageV.contentMode = UIViewContentModeScaleAspectFit;
        _arrowImageV.image = [UIImage imageNamed:@"mine_arrow"];
    }
    return _arrowImageV;
}

@end
